Expand description
§Raw (unsafe) bindings for Oboe library
Oboe is a C++ library which makes it easy to build high-performance audio apps on Android. It was created primarily to allow developers to target a simplified API that works across multiple API levels back to API level 16 (Jelly Bean).
Usually you shouldn’t use this crate directly, instead use oboe crate which provides safe interface.
Structs§
- Base class for Oboe C++ audio stream.
- Base class containing parameters for audio streams and builders.
- Factory class for an audio Stream.
- AudioStreamCallback defines a callback interface for:
- AudioStreamDataCallback defines a callback interface for moving data to/from an audio stream using
onAudioReady
2) being alerted when a stream has an error usingonError*
methods - AudioStreamErrorCallback defines a callback interface for being alerted when a stream has an error or is disconnected using
onError*
methods. - On API 16 to 26 OpenSL ES will be used. When using OpenSL ES the optimal values for sampleRate and framesPerBurst are not known by the native code. On API 17+ these values should be obtained from the AudioManager using this code:
- The time at which the frame at
position
was presented - LatencyTuner can be used to dynamically tune the latency of an output stream. It adjusts the stream’s bufferSize by monitoring the number of underruns.
- A ResultWithValue can store both the result of an operation (either OK or an error) and a value.
- This struct is a stateless functor which closes an AudioStream prior to its deletion. This means it can be used to safely delete a smart pointer referring to an open stream.
- Oboe versioning object
Constants§
- Indicates that the audio may be captured by any app.
- Indicates that the audio may not be recorded by any app, even if it is a system app.
- Indicates that the audio may only be captured by system apps.
- When not explicitly requested, set privacy sensitive mode according to the Usage. This should behave similarly to setting AllowedCapturePolicy::All.
- Try to use AAudio. Fail if unavailable. AAudio was first supported in Android 8, API 26 and above. It is only recommended for API 27 and above.
- Use OpenSL ES. Note that OpenSL ES is deprecated in Android 13, API 30 and above.
- Try to use AAudio. If not available then use OpenSL ES.
- Single precision floating point.
- Signed 16-bit integers.
- Signed 24-bit integers, packed into 3 bytes.
- Signed 32-bit integers.
- This format is used for compressed audio wrapped in IEC61937 for HDMI or S/PDIF passthrough.
- Invalid format.
- Unspecified format. Format will be decided by Oboe. When calling getHardwareFormat(), this will be returned if the API is not supported.
- Use this for mono audio
- Use this for stereo audio.
- Audio channel count definition, use Mono or Stereo
- Supported for Input and Output
- Supported for only Output
- Supported for Input and Output
- Supported for Input and Output
- Supported for only Output
- Supported for Input and Output
- Supported for Input and Output. aka 5Point1Back
- Supported for only Output
- Supported for only Output
- Supported for only Output
- Supported for only Output
- Supported for only Output
- Supported for only Output
- Supported for only Output
- Supported for only Output
- Supported for only Output
- Supported for only Input
- Supported for Input and Output
- Supported for only Output
- Supported for only Output
- Supported for only Output
- Supported for Input and Output
- Supported for only Output
- Supported for only Output
- Supported for only Output
- Use this for a movie or video soundtrack.
- Use this for pre-recorded or live music.
- Use this for sound is designed to accompany a user action, such as a click or beep sound made when the user presses a button.
- Use this for spoken voice, audio books, etcetera.
- Used for recording.
- Used for playback.
- Use this preset when recording video.
- Use this preset when other presets do not apply.
- Use this preset to obtain an input with no effects. Note that this input will not have automatic gain control so the recorded volume may be very low.
- Use this preset when doing telephony or voice messaging.
- Use this preset for capturing audio meant to be processed in real time and played back for live performance (e.g karaoke). The capture path will minimize latency and coupling with playback path.
- Use this preset when doing speech recognition.
- Reducing latency is most important.
- No particular performance needs. Default.
- Extending battery life is most important.
- Privacy sensitive mode disabled.
- Privacy sensitive mode enabled.
- When not explicitly requested, set privacy sensitive mode according to input preset: communication and camcorder captures are considered privacy sensitive by default.
- Highest quality conversion, which may be expensive in terms of CPU.
- Fastest conversion but may not sound great. This may be implemented using bilinear interpolation.
- High quality conversion with 32 taps.
- Low quality conversion with 8 taps.
- Medium quality conversion with 16 taps.
- No conversion by Oboe. Underlying APIs may still do conversion.
- Allocate a session ID that can be used to attach and control effects using the Java AudioEffects API. Note that the use of this flag may result in higher latency.
- Do not allocate a session ID. Effects cannot be used with this stream. Default.
- This will be the only stream using a particular source or sink. This mode will provide the lowest possible latency. You should close EXCLUSIVE streams immediately when you are not using them.
- Multiple applications can share the same device. The data from output streams will be mixed by the audio service. The data for input streams will be distributed by the audio service.
- Constant indicating the audio content associated with these attributes will follow the default platform behavior with regards to which content will be spatialized or not.
- Constant indicating the audio content associated with these attributes should never be spatialized.
- Constant indicating that the spatialization behavior is not specified.
- Use this to demand the users attention.
- Use this for screen readers, etcetera.
- Use this for driving or navigation directions.
- Use this for user interface sounds, beeps, etcetera.
- Use this for audio responses to user queries, audio instructions or help utterances.
- Use this for game audio and sound effects.
- Use this for streaming media, music performance, video, podcasts, etcetera.
- Use this for notifying the user when a message has arrived or some other background event has occured.
- Use this to attract the users attention when, for example, the battery is low.
- Use this when the phone rings.
- Use this for voice over IP, telephony, etcetera.
- Use this for sounds associated with telephony such as busy tones, DTMF, etcetera.
- This is incremented when we make breaking API changes. Based loosely on https://semver.org/.
- This is incremented when we add backwards compatible functionality. Or set to zero when MAJOR is incremented.
- Integer representation of the current Oboe library version. This will always increase when the version number changes so can be compared using integer comparison.
- This is incremented when we make backwards compatible bug fixes. Or set to zero when MINOR is incremented.
- Version string in the form MAJOR.MINOR.PATCH.
Statics§
- The default channel count to use when opening new audio streams
- The default frames per burst to use when opening new audio streams
- The default sample rate to use when opening new audio streams
Functions§
- Is the AAudio API recommended this device?
- Is the AAudio API supported on this device?
- Construct an
AudioStream
using the givenAudioStreamBuilder
- This should only be called as a stream is being opened. Otherwise we might override setDelayBeforeCloseMillis().
- Close the stream and deallocate any resources from the open() call.
- Override this to provide your own behaviour for the audio callback
- Flush the stream. This will block until the stream has been flushed, an error occurs or
timeoutNanoseconds
has been reached. - @return number of frames of data currently in the buffer
- Get the number of bytes per sample. This is calculated using the sample format. For example, a stream using 16-bit integer samples will have 2 bytes per sample.
- The number of audio frames read from the stream. This monotonic counter will never get reset.
- The number of audio frames written into the stream. This monotonic counter will never get reset.
- Get the estimated time that the frame at
framePosition
entered or left the audio processing pipeline. - Pause the stream. This will block until the stream has been paused, an error occurs or
timeoutNanoseconds
has been reached. - Start the stream. This will block until the stream has been started, an error occurs or
timeoutNanoseconds
has been reached. - Stop the stream. This will block until the stream has been stopped, an error occurs or
timeoutNanoseconds
has been reached. - Wait until the stream has a minimum amount of data available in its buffer. This can be used with an EXCLUSIVE MMAP input stream to avoid reading data too close to the DSP write position, which may cause glitches.
- Wait for a transition from one state to another. @return OK if the endingState was observed, or ErrorUnexpectedState if any state that was not the startingState or endingState was observed or ErrorTimeout.
- Construct a new LatencyTuner object which will act on the given audio stream
- Construct a new LatencyTuner object which will act on the given audio stream.
- @return true if the audio stream’s buffer size is at the maximum value. If no maximum value was specified when constructing the LatencyTuner then the value of stream->getBufferCapacityInFrames is used
- This may be called from another thread. Then tune() will call reset(), which will lower the latency to the minimum and then allow it to rise back up if there are glitches.
- Adjust the bufferSizeInFrames to optimize latency. It will start with a low latency and then raise it if an underrun occurs.
- Return the version of the SDK that is currently running.
Type Aliases§
- Specifies whether audio may or may not be captured by other apps or the system for an output stream.
- The underlying audio API used by the audio stream.
- The format of audio samples.
- The channel count of the audio stream. The underlying type is
int32_t
. Use of this enum is convenient to avoid “magic” numbers when specifying the channel count. - The channel mask of the audio stream. The underlying type is
uint32_t
. Use of this enum is convenient. - The ContentType attribute describes what you are playing. It expresses the general category of the content. This information is optional. But in case it is known (for instance {@link Movie} for a movie streaming service or {@link Speech} for an audio book application) this information might be used by the audio framework to enforce audio focus.
- The result of an audio callback.
- The direction of the stream.
- Defines the audio source. An audio source defines both a default physical source of audio signal, and a recording configuration.
- The performance mode of the audio stream.
- The PrivacySensitiveMode attribute determines whether an input stream can be shared with another privileged app, for example the Assistant.
- The result of an operation. All except the
OK
result indicates that an error occurred. TheResult
can be converted into a human readable string usingconvertToText
. - Specifies the quality of the sample rate conversion performed by Oboe. Higher quality will require more CPU load. Higher quality conversion will probably be implemented using a sinc based resampler.
- This attribute can be used to allocate a session ID to the audio stream.
- The sharing mode of the audio stream.
- The spatialization behavior of the audio stream.
- The state of the audio stream.
- The Usage attribute expresses why you are playing a sound, what is this sound used for. This information is used by certain platforms or routing policies to make more refined volume or routing decisions.